import moment from 'moment';
import { parse } from 'url';
// mock data
const visitData = [];
const beginDay = new Date().getTime();

const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];
for (let i = 0; i < fakeY.length; i += 1) {
  visitData.push({
    x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
    y: fakeY[i],
  });
}

const visitData2 = [];
const fakeY2 = [1, 6, 4, 8, 3, 7, 2];
for (let i = 0; i < fakeY2.length; i += 1) {
  visitData2.push({
    x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
    y: fakeY2[i],
  });
}

const salesData = [];
for (let i = 0; i < 12; i += 1) {
  salesData.push({
    x: `${i + 1}月`,
    y: Math.floor(Math.random() * 1000) + 200,
  });
}
const searchData = [];
for (let i = 0; i < 50; i += 1) {
  searchData.push({
    index: i + 1,
    keyword: `搜索关键词-${i}`,
    count: Math.floor(Math.random() * 1000),
    range: Math.floor(Math.random() * 100),
    status: Math.floor((Math.random() * 10) % 2),
  });
}


//人员信息数据
const staffInfoDataByArea = [
  {
    x: '河南',
    y: 100,
  },
  {
    x: '河北',
    y: 120,
  },
  {
    x: '北京',
    y: 300,
  },
  {
    x: '上海',
    y: 280,
  },
  {
    x: '广州',
    y: 150,
  },
  {
    x: '山东',
    y: 180,
  },
  {
    x: '山东',
    y: 180,
  },
  {
    x: '山东1',
    y: 180,
  },
];

const staffInfoDataByStaffNation = [
  {
    x: '汉族',
    y: 80,
  },
  {
    x: '回族',
    y: 60,
  },
  {
    x: '藏族',
    y: 40,
  },
  {
    x: '蒙古族',
    y: 45,
  },
  {
    x: '满族',
    y: 30,
  },
  {
    x: '维吾尔族',
    y: 28,
  },
];

const staffInfoDataByType = [
  {
    x: '综合管理类',
    y: 120,
  },
  {
    x: '专业技术类',
    y: 130,
  },
  {
    x: '行政执法类',
    y: 150,
  },
  {
    x: '机关工勤人员',
    y: 280,
  },
  {
    x: '机关事业人员',
    y: 125,
  },
  {
    x: '企业管理人员',
    y: 110,
  },
];


const staffInfoDataByPoliticsFace = [
  {
    x: '中共党员',
    y: 130,
  },
  {
    x: '预备党员',
    y: 200,
  },
  {
    x: '共青团员',
    y: 140,
  },
  {
    x: '民进',
    y: 120,
  },
  {
    x: '农工党',
    y: 90,
  },
  {
    x: '群众',
    y: 60,
  },
];


const staffInfoDataByPostType = [
  {
    x: '综合管理警官',
    y: 100,
  },
  {
    x: '综合管理警员',
    y: 230,
  },
  {
    x: '执法勤务警官',
    y: 90,
  },
  {
    x: '执法勤务警员',
    y: 180,
  },
  {
    x: '警务技术警官',
    y: 88,
  },
  {
    x: '警务技术警员',
    y: 190,
  },
];



//机构信息数据
const organInfoData = [
  {
    x: '河南',
    y: 10,
    value: '30330',
  },
  {
    x: '河北',
    y: 12,
  },
  {
    x: '北京',
    y: 30,
  },
  {
    x: '上海',
    y: 28,
  },
  {
    x: '广州',
    y: 15,
  },
  {
    x: '山东',
    y: 18,
  },
];

const organInfoDataByType = [
  {
    x: '一级公安机关',
    y: 20,
  },
  {
    x: '内设机构',
    y: 22,
  },
  {
    x: '直属机关',
    y: 38,
  },
  {
    x: '派出机构',
    y: 50,
  },
  {
    x: '事业单位',
    y: 80,
  },
  {
    x: '其他',
    y: 15,
  },
];

const organInfoDataByLevel = [
  {
    x: '中央国家级',
    y: 10,
  },
  {
    x: '省部级',
    y: 20,
  },
  {
    x: '县处级',
    y: 80,
  },
  {
    x: '乡科级',
    y: 150,
  },
  {
    x: '国际组织机构',
    y: 15,
  },
  {
    x: '其他',
    y: 20,
  },
];

//警力分布统计数据
const policeSpreadData = [
  {
    x: '河南',
    y: 100,
    ratio: '5.00'
  },
  {
    x: '河北',
    y: 120,
    ratio: '6.12'
  },
  {
    x: '北京',
    y: 210,
    ratio: '5.53'
  },
  {
    x: '上海',
    y: 218,
    ratio: '5.00'
  },
  {
    x: '广州',
    y: 150,
    ratio: '4.43'
  },
  {
    x: '山东',
    y: 180,
    ratio: '6.00'
  },
];

const policeDataByDutyLevel = [
  {
    x: '人民警察警员',
    y: 30,
  },
  {
    x: '执法勤务警员',
    y: 38,
  },
  {
    x: '警务技术类警员',
    y: 40,
  },
  {
    x: '综合管理类警员',
    y: 50,
  },
  {
    x: '专业技术职务',
    y: 45,
  },
  {
    x: '军队干部',
    y: 20,
  },
];

const policeDataByPoliceRank = [
  {
    x: '警监',
    y: 20,
  },
  {
    x: '警督',
    y: 35,
  },
  {
    x: '警司',
    y: 40,
  },
  {
    x: '警员',
    y: 55,
  },
];

//编制统计数据
const formationData = [
  {
    x: '批准编制',
    y: 20,
  },
  {
    x: '政法专项编制',
    y: 16,
  },
  {
    x: '事业编制',
    y: 22,
  },
  {
    x: '其他编制',
    y: 30,
  },
];

//职数统计数据
const positionData = [
  {
    x: '人民警察警员',
    y: 10,
  },
  {
    x: '执法勤务警员',
    y: 28,
  },
  {
    x: '警务技术类警员',
    y: 30,
  },
  {
    x: '综合管理类警员',
    y: 40,
  },
  {
    x: '专业技术职务',
    y: 35,
  },
  {
    x: '军队干部',
    y: 13,
  },
];

const salesTypeData = [
  {
    x: '乔木',
    y: 4544,
  },
  {
    x: '灌木',
    y: 3321,
  },
  {
    x: '松树',
    y: 3113,
  },
  {
    x: '柏树',
    y: 2341,
  },
  {
    x: '槐树',
    y: 1231,
  },
  {
    x: '其他',
    y: 1231,
  },
];



const salesTypeDataOnline = [
  {
    x: '老鼠',
    y: 244,
  },
  {
    x: '昆虫',
    y: 321,
  },
  {
    x: '大象',
    y: 311,
  },
  {
    x: '龙虾',
    y: 41,
  },
  {
    x: '鲸鱼',
    y: 121,
  },
  {
    x: '其他',
    y: 111,
  },
];

const salesTypeDataOffline = [
  {
    x: '松鼠',
    y: 99,
  },
  {
    x: '老虎',
    y: 188,
  },
  {
    x: '鱼',
    y: 344,
  },
  {
    x: '豹子',
    y: 255,
  },
  {
    x: '其他',
    y: 65,
  },
];

const offlineData = [];
for (let i = 0; i < 10; i += 1) {
  offlineData.push({
    name: `种类 ${i}`,
    cvr: Math.ceil(Math.random() * 9) / 10,
  });
}
const offlineChartData = [];
for (let i = 0; i < 20; i += 1) {
  offlineChartData.push({
    x: new Date().getTime() + 1000 * 60 * 30 * i,
    y1: Math.floor(Math.random() * 100) + 10,
    y2: Math.floor(Math.random() * 100) + 10,
  });
}

const radarOriginData = [
  {
    name: '个人',
    ref: 10,
    koubei: 8,
    output: 4,
    contribute: 5,
    hot: 7,
  },
  {
    name: '团队',
    ref: 3,
    koubei: 9,
    output: 6,
    contribute: 3,
    hot: 1,
  },
  {
    name: '部门',
    ref: 4,
    koubei: 1,
    output: 6,
    contribute: 5,
    hot: 7,
  },
];

const radarData = [];
const radarTitleMap = {
  ref: '引用',
  koubei: '农林',
  output: '产量',
  contribute: '贡献',
  hot: '热度',
};
radarOriginData.forEach(item => {
  Object.keys(item).forEach(key => {
    if (key !== 'name') {
      radarData.push({
        name: item.name,
        label: radarTitleMap[key],
        value: item[key],
      });
    }
  });
});

    let tableListDataByStaffTotal = [
			{ordernum:"1", nation:"汉族", politics_face:"中共党员", person_type:"机关工勤人员", post_type:"综合管理警官",total: 10},
			{ordernum:"2",nation:"蒙古族", politics_face:"预备党员", person_type:"企业工勤人员", post_type:"综合管理警员",total: 20},
			{ordernum:"3",nation:"回族", politics_face:"中共党员", person_type:"企业管理人员", post_type:"执法勤务警官",total: 15},
			{ordernum:"4",nation:"满族", politics_face:"民进", person_type:"机关工勤人员", post_type:"执法勤务警员",total: 18},
			{ordernum:"5",nation:"维吾尔族", politics_face:"农工党", person_type:"专业技术类", post_type:"警务技术警官",total: 12},
			{ordernum:"6",nation:"藏族", politics_face:"群众", person_type:"专业技术类", post_type:"警务技术警员",total: 10},
		]

    function getProStaffList(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
    	console.log(params);
      let dataSource = tableListDataByStaffTotal;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByStaffDetail = [
			{name:"阳泰顺", sex:"女", nation:"汉族", politics_face:"中共党员", person_type:"机关工勤人员", post_type:"综合管理警官"},
			{name:"鲍翰东", sex:"男", nation:"蒙古族", politics_face:"预备党员", person_type:"企业工勤人员", post_type:"综合管理警员"},
			{name:"姜成发", sex:"男", nation:"回族", politics_face:"中共党员", person_type:"企业管理人员", post_type:"执法勤务警官"},
			{name:"谷军", sex:"男", nation:"满族", politics_face:"民进", person_type:"机关工勤人员", post_type:"执法勤务警员"},
			{name:"宋宜仪", sex:"女", nation:"维吾尔族", politics_face:"农工党", person_type:"专业技术类", post_type:"警务技术警官"},
			{name:"王成", sex:"男", nation:"藏族", politics_face:"群众", person_type:"专业技术类", post_type:"警务技术警员"},
		]

    function getProStaffDetail(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
    	console.log(params);
      let dataSource = tableListDataByStaffDetail;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByOrganTotal = [
      {ordernum: "1",type_of_unit:"一级公安机关", unit_level:"市级", administrative_area:"内蒙古呼和浩特市",total: 10},
      {ordernum: "2",type_of_unit:"公安行政机关", unit_level:"县、处级", administrative_area:"北京市",total: 18},
      {ordernum: "3",type_of_unit:"一级公安机关", unit_level:"市级", administrative_area:"天津市",total: 20},
      {ordernum: "4",type_of_unit:"二级公安机关", unit_level:"县、处级", administrative_area:"上海市",total: 8},
      {ordernum: "5",type_of_unit:"二级公安机关", unit_level:"县、处级", administrative_area:"石家庄",total: 12},
      {ordernum: "6",type_of_unit:"一级公安机关", unit_level:"市级", administrative_area:"重庆",total: 10},
    ]

    function getProOrganList(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
      let dataSource = tableListDataByOrganTotal;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByOrganDetail = [
      {unit_superior_unit:"乌兰察布市公安局", unit_affiliation:"省辖市", type_of_unit:"一级公安机关", unit_level:"县、处级", administrative_area:"内蒙古呼和浩特市"},
      {unit_superior_unit:"呼和浩特市公安局", unit_affiliation:"省辖市", type_of_unit:"公安行政机关", unit_level:"县、处级", administrative_area:"内蒙古呼和浩特市"},
      {unit_superior_unit:"包头市公安局", unit_affiliation:"省辖市", type_of_unit:"一级公安机关", unit_level:"县、处级", administrative_area:"内蒙古呼和浩特市"},
      {unit_superior_unit:"乌海市公安局", unit_affiliation:"省辖市", type_of_unit:"一级公安机关", unit_level:"县、处级", administrative_area:"内蒙古呼和浩特市"},
      {unit_superior_unit:"赤峰市公安局", unit_affiliation:"省辖市", type_of_unit:"一级公安机关", unit_level:"县、处级", administrative_area:"内蒙古呼和浩特市"},
      {unit_superior_unit:"赤峰市公安局", unit_affiliation:"省辖市", type_of_unit:"一级公安机关", unit_level:"县、处级", administrative_area:"内蒙古乌兰察布市"},
      {unit_superior_unit:"赤峰市公安局", unit_affiliation:"省辖市", type_of_unit:"一级公安机关", unit_level:"县、处级", administrative_area:"内蒙古乌兰察布市"},
    ]

    function getProOrganDetail(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
      let dataSource = tableListDataByOrganDetail;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByPoliceTotal = [
      {ordernum: "1",company_area:"北京", duty_level:"二级警长",police_rank:"二级警督",total: 20},
      {ordernum: "2",company_area:"天津", duty_level:"二级警长",police_rank:"二级警督",total: 16},
      {ordernum: "3",company_area:"上海", duty_level:"一级警长",police_rank:"一级警督",total: 22},
      {ordernum: "4",company_area:"北京", duty_level:"二级警长",police_rank:"二级警督",total: 30},
      {ordernum: "5",company_area:"重庆", duty_level:"三级警长",police_rank:"三级警督",total: 12},
      {ordernum: "6",company_area:"深圳", duty_level:"一级警长",police_rank:"一级警督",total: 15},
    ]

    function getProPoliceList(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
      let dataSource = tableListDataByPoliceTotal;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByPoliceDetail = [
      {name:"陈某", sex:"男",company_area:"北京",post:"主任科员",duty_level:"二级警长",police_rank:"二级警督"},
      {name:"王某", sex:"男",company_area:"北京",post:"主任科员",duty_level:"二级警长",police_rank:"二级警督"},
      {name:"李某", sex:"男",company_area:"北京",post:"主任科员",duty_level:"二级警长",police_rank:"二级警督"},
      {name:"张某", sex:"男",company_area:"北京",post:"主任科员",duty_level:"二级警长",police_rank:"二级警督"},
      {name:"姜某", sex:"男",company_area:"北京",post:"主任科员",duty_level:"二级警长",police_rank:"二级警督"},
      {name:"赵某", sex:"男",company_area:"北京",post:"主任科员",duty_level:"二级警长",police_rank:"二级警督"},
      {name:"钱某", sex:"男",company_area:"北京",post:"主任科员",duty_level:"二级警长",police_rank:"二级警督"},
    ]

    function getProPoliceDetail(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
      let dataSource = tableListDataByPoliceDetail;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByFormationTotal = [
      {ordernum: "1",formation_type:"批准编制",total: 20},
      {ordernum: "2",formation_type:"政法专项编制",total: 16},
      {ordernum: "3",formation_type:"事业编制",total: 22},
      {ordernum: "4",formation_type:"其他编制",total: 30}
    ]

    function getProFormationList(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
      let dataSource = tableListDataByFormationTotal;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByFormationDetail = [
      {unit_superior_unit:"乌兰察布市公安局", formation_type: "批准编制", unit_level:"市级", administrative_area:"乌兰察布市",approve_unit: "乌兰察布市人民政府",approve_time: "2017-08-09"},
    	{unit_superior_unit:"呼和浩特市公安局", formation_type: "批准编制",unit_level:"市级", administrative_area:"呼和浩特市",approve_unit: "呼和浩特市人民政府",approve_time: "2017-09-10"},
    	{unit_superior_unit:"包头市公安局", formation_type: "批准编制",unit_level:"市级", administrative_area:"包头市",approve_unit: "包头市人民政府",approve_time: "2018-10-10"},
    	{unit_superior_unit:"乌海市公安局", formation_type: "批准编制", unit_level:"市级", administrative_area:"乌海市",approve_unit: "乌海市人民政府",approve_time: "2018-09-10"},
    	{unit_superior_unit:"赤峰市公安局", formation_type: "批准编制",unit_level:"市级", administrative_area:"赤峰市",approve_unit: "赤峰市人民政府",approve_time: "2018-05-10"},
    	{unit_superior_unit:"天津市公安局", formation_type: "批准编制",unit_level:"市级", administrative_area:"天津市",approve_unit: "天津市人民政府",approve_time: "2016-09-10"}
    ]

    function getProFormationDetail(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

        const params = parse(url, true).query;
        let dataSource = tableListDataByFormationDetail;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByPositionTotal = [
      {ordernum: "1",duty_level:"人民警察警员",total: 20},
      {ordernum: "2",duty_level:"执法勤务警员",total: 16},
      {ordernum: "3",duty_level:"警务技术类警员",total: 22},
      {ordernum: "4",duty_level:"综合管理类警员",total: 18},
      {ordernum: "5",duty_level:"专业技术职务",total: 20},
      {ordernum: "6",duty_level:"军队干部",total: 30}
    ]

    function getProPositionList(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

      const params = parse(url, true).query;
      let dataSource = tableListDataByPositionTotal;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

    let tableListDataByPositionDetail = [
	    {company_area:"北京公安部",name:"陈某",sex:"男",duty_level:"二级警长",post:"主任科员"},
	    {company_area:"天津公安局",name:"王某",sex:"男",duty_level:"二级警长",post:"副局长"},
	    {company_area:"南京公安局",name:"李某",sex:"男",duty_level:"二级警长",post:"副主任科员"},
	    {company_area:"郑州公安局",name:"张某",sex:"男",duty_level:"二级警长",post:"主任科员"},
	    {company_area:"保定公安局",name:"姜某",sex:"男",duty_level:"二级警长",post:"主任科员"},
	    {company_area:"济南公安局",name:"赵某",sex:"男",duty_level:"二级警长",post:"副政委"},
	    {company_area:"上海公安局",name:"钱某",sex:"男",duty_level:"二级警长",post:"参谋"},
	]

    function getProPositionDetail(req, res, u) {
        let url = u;
        if (!url || Object.prototype.toString.call(url) !== '[object String]') {
            url = req.url; // eslint-disable-line
        }

        const params = parse(url, true).query;
        let dataSource = tableListDataByPositionDetail;

        if (params.work_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.superior_unit!=undefined){
    	        	return data.superior_unit.indexOf(params.work_unit) > -1;
    	        }

    	    });
        }

        if (params.company!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.company!=undefined){
    	        	return data.company.indexOf(params.company) > -1;
    	        }

    	    });
        }

        if (params.type_of_unit!=undefined) {
    	    dataSource = dataSource.filter(data => {

    	        if(data.type_of_unit!=undefined){
    	        	return data.type_of_unit.indexOf(params.type_of_unit) > -1;
    	        }

    	    });
        }

        let pageSize = 10;
        if (params.pageSize!=undefined) {
            pageSize = params.pageSize * 1;
        }

        const result = {
            list: dataSource,
            pagination: {
                total: dataSource.length,
                pageSize,
                current: parseInt(params.currentPage, 10) || 1,
            },
        };

        return res.json(result);
    }

const getFakeChartData = {
  visitData,
  visitData2,
  salesData,
  searchData,
  offlineData,
  offlineChartData,
  salesTypeData,
  salesTypeDataOnline,
  salesTypeDataOffline,
  radarData,

  staffInfoDataByArea,
  staffInfoDataByType,
  staffInfoDataByPoliticsFace,
  staffInfoDataByPostType,
  staffInfoDataByStaffNation,


  organInfoData,
  organInfoDataByType,
  organInfoDataByLevel,
  policeSpreadData,
  policeDataByPoliceRank,
  policeDataByDutyLevel,

  formationData,
  positionData
};

export default {
  'GET /api/fake_statisticchart_data': getFakeChartData,
  'POST /platform_server/web/api/service/stafflist/queryPage': getProStaffList,
  'POST /platform_server/web/api/service/staffdetail/queryPage': getProStaffDetail,
  'POST /platform_server/web/api/service/organlist/queryPage': getProOrganList,
  'POST /platform_server/web/api/service/organdetail/queryPage': getProOrganDetail,
  'POST /platform_server/web/api/service/policelist/queryPage': getProPoliceList,
  'POST /platform_server/web/api/service/policedetail/queryPage': getProPoliceDetail,
  'POST /platform_server/web/api/service/formationlist/queryPage': getProFormationList,
  'POST /platform_server/web/api/service/formationdetail/queryPage': getProFormationDetail,
  'POST /platform_server/web/api/service/positionlist/queryPage': getProPositionList,
  'POST /platform_server/web/api/service/positiondetail/queryPage': getProPositionDetail
};
